package com.uphone.kingmall.adapter;

import android.view.View;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.china.zhuoyue.R;
import com.uphone.kingmall.activity.order.OrderDetailActivity;
import com.uphone.kingmall.bean.MessageBean;
import com.uphone.kingmall.utils.CommonUtil;

/**
 * author : SuMeng
 * e-mail : 986335838@qq.com
 * time   : 2019/02/18
 * desc   : 通知消息adpater
 */
public class MessageNotifactionListAdpater extends BaseQuickAdapter<MessageBean.DataBean, BaseViewHolder> {

    public MessageNotifactionListAdpater() {
        super(R.layout.kingmall_item_message_notifaction);
    }

    @Override
    protected void convert(final BaseViewHolder helper, final MessageBean.DataBean item) {
        helper.setText(R.id.tv_title, item.getMsgTitle());
//        1订单，2充值提现，3分红，4审核，5投诉
        RecyclerView recycleview = helper.getView(R.id.recyclerView);
        TextView tv_content = helper.getView(R.id.tv_content);
        if (item.getMsgMode() == 1) {
            recycleview.setVisibility(View.VISIBLE);
            tv_content.setVisibility(View.GONE);
            recycleview.setLayoutManager(new LinearLayoutManager(mContext));
            MessageNotiItemAdapter adapter = new MessageNotiItemAdapter();
            recycleview.setAdapter(adapter);
            adapter.setNewData(item.getOrderGoods());
            adapter.setOnItemClickListener(new OnItemClickListener() {
                @Override
                public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                    CommonUtil.startIntent(mContext, OrderDetailActivity.class, Integer.parseInt(item.getTag()));
                }
            });
        } else {
            helper.setText(R.id.tv_content, item.getMsgContent());
            recycleview.setVisibility(View.GONE);
            tv_content.setVisibility(View.VISIBLE);
        }
    }
}